import { ValidationResult } from "../types";

/**
 * 必填验证规则选项接口
 * 该接口无额外配置选项
 */
export interface RequiredValidationOptions {
}

/**
 * 必填验证规则
 * @param {any} value - 要验证的值
 * @returns {ValidationResult} 验证结果
 * @example
 * // 直接调用
 * const result = validateRequired('test');
 * console.log(result); // { valid: true, message: undefined }
 * 
 * // 使用validateRule
 * const ruleResult = validateRule('', { type: 'required' });
 * console.log(ruleResult); // { valid: false, message: '此字段为必填项' }
 */
export function validateRequired(value: any): ValidationResult {
    const isValid = value !== undefined && value !== null && value !== '';
    return {
        valid: isValid,
        message: isValid ? undefined : '此字段为必填项'
    };
}